package handlers

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"ys/models"
)

func Add(c *gin.Context) {
	name := c.PostForm("name")
	tel := c.PostForm("tel")
	ke := c.PostForm("ke")
	price := c.PostForm("price")
	gh := models.Gh{
		Name:  name,
		Tel:   tel,
		Ke:    ke,
		Price: price,
	}
	models.DB.Create(&gh)
	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "添加成功",
		"data": gh,
	})
	return
}

func List(c *gin.Context) {
	var gh []models.Gh
	models.DB.Find(&gh)
	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "展示成功",
		"data": gh,
	})
	return
}
